package cn.stylefeng.guns.modular.manager.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.manager.entity.FlowAbout;
import cn.stylefeng.guns.modular.manager.model.params.FlowAboutParam;
import cn.stylefeng.guns.modular.manager.service.FlowAboutService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;


/**
 * 关于公司控制器
 *
 * @author yumker
 * @Date 2021-01-07 17:22:24
 */
@Controller
@RequestMapping("/flowAbout")
public class FlowAboutController extends BaseController {

    private String PREFIX = "/manager/flowAbout";

    @Autowired
    private FlowAboutService flowAboutService;

    /**
     * 跳转到主页面
     *
     * @author yumker
     * @Date 2021-01-07
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/flowAbout.html";
    }

    /**
     * 编辑接口
     *
     * @author yumker
     * @Date 2021-01-07
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(FlowAboutParam flowAboutParam) {
        if(!StringUtils.isEmpty(flowAboutParam.getDetail())){
            try {
                flowAboutParam.setDetail(URLDecoder.decode(flowAboutParam.getDetail(),"UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        this.flowAboutService.update(flowAboutParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author yumker
     * @Date 2021-01-07
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail() {
        FlowAboutParam flowAboutParam = new FlowAboutParam();
        flowAboutParam.setAboutId(1L);
        FlowAbout detail = this.flowAboutService.getById(flowAboutParam.getAboutId());
        return ResponseData.success(detail);
    }
}


